package com.entity;

import javax.persistence.*;
import java.util.Set;

/**
 * Created by Administrator on 2015/7/22.
 */
@Entity
public class District {
    private int districtId;
    private String districtName;
    private Set<Street> streets;


    @Id
    @Column(name = "district_id")
    public int getDistrictId() {
        return districtId;
    }

    public void setDistrictId(int districtId) {
        this.districtId = districtId;
    }

    @Basic
    @Column(name = "district_name")
    public String getDistrictName() {
        return districtName;
    }

    public void setDistrictName(String districtName) {
        this.districtName = districtName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        District district = (District) o;

        if (districtId != district.districtId) return false;
        if (districtName != null ? !districtName.equals(district.districtName) : district.districtName != null)
            return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = districtId;
        result = 31 * result + (districtName != null ? districtName.hashCode() : 0);
        return result;
    }

    @OneToMany(mappedBy = "district")
    public Set<Street> getStreets() {
        return streets;
    }

    public void setStreets(Set<Street> streets) {
        this.streets = streets;
    }
}
